package com.traveldream.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the place database table.
 * 
 */
@Entity
@NamedQueries({
	@NamedQuery(name="Place.findAll", query="SELECT p FROM Place p"),
	@NamedQuery(name="Place.findByInitials", query="SELECT p FROM Place p WHERE p.name LIKE :init")
})

public class Place implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private String name;

	//bi-directional many-to-one association to Flight
	@OneToMany(mappedBy="place")
	private List<Flight> flights;

	//bi-directional many-to-one association to Packet
	@OneToMany(mappedBy="place")
	private List<Packet> packets;

	//bi-directional many-to-one association to Product
	@OneToMany(mappedBy="place")
	private List<Product> products;

	public Place() {
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Flight> getFlights() {
		return this.flights;
	}

	public void setFlights(List<Flight> flights) {
		this.flights = flights;
	}

	public Flight addFlight(Flight flight) {
		getFlights().add(flight);
		flight.setPlace(this);

		return flight;
	}

	public Flight removeFlight(Flight flight) {
		getFlights().remove(flight);
		flight.setPlace(null);

		return flight;
	}

	public List<Packet> getPackets() {
		return this.packets;
	}

	public void setPackets(List<Packet> packets) {
		this.packets = packets;
	}

	public Packet addPacket(Packet packet) {
		getPackets().add(packet);
		packet.setPlace(this);

		return packet;
	}

	public Packet removePacket(Packet packet) {
		getPackets().remove(packet);
		packet.setPlace(null);

		return packet;
	}

	public List<Product> getProducts() {
		return this.products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	public Product addProduct(Product product) {
		getProducts().add(product);
		product.setPlace(this);

		return product;
	}

	public Product removeProduct(Product product) {
		getProducts().remove(product);
		product.setPlace(null);

		return product;
	}

}